<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/8/9
  Time: 14:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>嗨购管理平台</title>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/static/img/higou.png" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        #body {
            width: 100%;
            height: 650px;
            background-color:#ede7e1;
            padding-top: 20px;
            overflow: hidden;
        }
        #kid {
            width: 960px;
            height: 550px;
            background-color: white;
            margin: 0 auto;
            padding-top: 10px;
            padding-left: 10px;
            border-radius: 5px;
            overflow: hidden;
        }
        #kid_left{
            width: 148px;
            height: 500px;
            border-right:1px dotted lightgray ;
            display: inline-block;
            float: left;
        }
        .centerLeft {
            width: 160px;
            display: inline-block;
            position: absolute;
            top: 100px;
            margin-left: -12px;
            box-sizing: border-box;

        }
        /*.centerLeft  .dingdan a{
             color: #e4393c;
             background-color: white;
            }*/
        .shang {
            width: 100%;
            height:230px;
        }
        .shang2{
            width: 100%;
            height: 137px;
            margin-top: -49px;
            margin-bottom: 47px;
        }
        .title {
            width: 100%;
            height: 41px;
            background: lightgrey;
            color: #333;
            font-size: 18px;
            line-height: 41px;
            vertical-align: middle;
        }
        .zi{
            display: inline-block;
            vertical-align: top;
        }
        .shang>ul {
            width: 159px;
            height: 141px;
        }
        .shang2>ul {
            width: 159px;
            height: 141px;
        }
        .shang>ul>li {
            width: 159px;
            height: 46.8px;
            background-color: #ede7e1;
            border-bottom: 1px solid lightgray;
            border-left: 1px solid lightgray;
        }
        .shang2>ul>li {
            width: 159px;
            height: 46.8px;
            background-color: #ede7e1;
            border-bottom: 1px solid lightgray;
            border-left: 1px solid lightgray;
        }
        .shang>ul a {
            display: inline-block;
            width: 100%;
            height: 100%;
            color: #666;
            line-height: 46.8px;
            text-align: center;
            text-decoration: none;
        }
        .shang2>ul a {
            display: inline-block;
            width: 100%;
            height: 100%;
            color: #666;
            line-height: 46.8px;
            text-align: center;
            text-decoration: none;
        }
        .kid_right{
            position:relative ;
            box-sizing: border-box;
            width: 802px;
            height: 680px;
            display: inline-block;
            float: left;

        }
        .kid_right > div {
            display: none;
        }
        .kid_right > div.dingdan {
            display: block;
        }
        .right_top{
            width: 796px;
            height: 46px;
            line-height: 46px;
            border-bottom: 1px solid #dbd6d0;
            font-weight: 400;
            position: relative;
            padding-left: 15px;
            overflow: hidden;
            font-size: 18px;
            display: block;
            color: #333;
        }
        .op{
            width: 140px;
            height: 23px;
            font-size: 14px;
            margin-left: 12px;
            border-radius: 2px;
        }
        #daochu{
            position: absolute;
            top:450px;
            left: 650px;

        }
        .z{
            margin-left: 15px;
        }
        input:focus{
            outline: none;
            box-shadow: none;
        }
        .money>table,.dingdan>table{
            width: 600px;
            text-align: center;
            margin-left: 80px;
            margin-top: 20px;
        }
        #dao{
            float: right;
            margin-right: 122px;
        }
        #mingxi{
            margin-left: 20px;
            text-align: center;
            height: 450px;
            overflow: scroll;
        }
        #liang{
            font-size: 16px;
            margin-top: 20px;
            margin-left: 20px;
        }
        #toptop{
            width: 100%;
            height:80px;
            background:#eee;
        }
        marquee{
            behavior:scroll;
            direction:left;
            scrollamount:5;
            color: red;
            margin-top: -50px;
            font-size: 20px;
        }
        #wel{
            width: 700px;
            margin: 0 auto;
            margin-top: -30px;
        }
        #hu{
            float: right;
            margin-right: 160px;
            display: inline-block;
            margin-top: -50px;
            font-weight: 700;
            font-size: 16px;
        }
        #uuu{
            text-align: center;

        }
        #time{
            float: right;
            margin-right: 120px;
            margin-top: -30px;
            font-size: 16px;
        }
        #logoo{
            width: 150px;
            height: 70px;
            margin-left: 170px;
            padding-top: 10px;
        }
        #shangpin{
            margin-top: 30px;
            margin-left: 20px;
        }
        #tianjia{
            margin-left: 50px;

        }

        .ti{
            margin-top: 20px;
            margin-left: 250px;
        }
        .shu>input{
            width: 122px;
            height: 41px;
            line-height: 41px;
            border-radius: 3px 3px 0 0;
            background-color: #f8f6f4;
            border: 1px solid #dbd6d0;
            border-bottom: 0;
            text-decoration: none;
            padding: 0 20px;
            color: #666;
            float: left;
            margin-right: -1px;
            margin-top: 15px;
            text-align: center;

        }
        #imgBox>#imgBox1,#imgBox>#imgBox2,#imgBox>#imgBox3,#imgBox>#imgBox4{
            display: flex;
            flex-wrap: wrap;
        }
        #imgBox>#imgBox2,#imgBox>#imgBox3,#imgBox>#imgBox4{
            display: none;
        }
        .xian{
            width: 769px;
            height: 150px;
            border: 1px solid #DBD6D0;
            margin-top: 38px;
            text-align: center;
            padding: 200px 0;
            margin-left: 15px;
        }
        .tian{
            margin-left: 150px;
            margin-top: -50px;
        }
        .fenye{
            position: absolute;
            top: 450px;
            left: 300px;
        }
        #popp{width:400px;height:200px;border:solid 1px #000;position:fixed;left:50%;top:50%;margin-left:-250px;margin-top:-200px;border:solid 1px #000;border-radius:5px;background:#fff;display:none;z-index:22}
        #lightboxx{  width:100%;height:100%;position:fixed;top:0;left:0;background:#000;filter:alpha(opacity=50);opacity:.5;display:none;}
    </style>
</head>

<body>
<div id="toptop">
    <div id="topleft">
        <div id="logoo">
            <img src="${pageContext.request.contextPath}/static/img/higou.png"/>
        </div>
        <div id="wel">
            <marquee>欢迎登录嗨购管理平台</marquee>
        </div>
    </div>
    <div id="topright">
        <div id="hu">
            [${sessionScope.mgr.m_no}]号管理员 您好！<a href="exit.jsp"> &lt;退出&gt;</a>
        </div>
        <div id="time"></div>
    </div>
</div>
<div id="body">
    <div id="kid">
        <div id="kid_left">
            <div class="centerLeft">
                <div class="shang">
                    <div class="title">
                        <img src="${pageContext.request.contextPath}/static/img/nav.png"  style="margin-left: -8px;"/>
                        <span class="zi">销售业绩</span>
                    </div>
                    <ul>
                        <li>
                            <a href="#container-myorder" >日销售量</a>
                        </li>
                        <li>
                            <a href="#container-money" >月销售量</a>
                        </li>
                        <li>
                            <a href="#container-star" >销售明星</a>
                        </li>
                    </ul>
                </div>
                <div class="shang2">
                    <div class="title">
                        <img src="${pageContext.request.contextPath}/static/img/nav.png"  style="margin-left: -8px;"/>
                        <span class="zi">用户管理中心</span>
                    </div>
                    <ul>

                        <li>
                            <a href="#container-luck-lottery">用户信息</a>
                        </li>
                        <li>
                            <a href="#container-password">访问量</a>
                        </li>
                    </ul>
                </div>

                <div class="shang2">
                    <div class="title">
                        <img src="${pageContext.request.contextPath}/static/img/nav.png"  style="margin-left: -8px;"/>
                        <span class="zi">商品管理中心</span>
                    </div>
                    <ul>

                        <li>
                            <a href="#container-add">添加商品</a>
                        </li>
                        <li>
                            <a  href="#container-del">商品明细</a>
                        </li>
                        <li>
                            <a href="#container-changing">促销与种类管理</a>
                        </li>
                    </ul>
                </div>

            </div>
        </div>
        <div class="kid_right">
            <div  id="container-myorder">
                <div class="right_top">
                    日销售量
                    <select class="op" id="select1" onchange="selectKind1()">
                        <option value="0">--请选择商品种类--</option>
                        <option value="男装">男装</option>
                        <option value="女装">女装</option>
                        <option value="运功户外">运动户外</option>
                        <option value="家居用品">家居用品</option>
                        <option value="医疗保健">医疗保健</option>
                        <option value="家具用品">家具用品</option>
                        <option value="洗化">洗化</option>
                        <option value="家电">家电</option>
                        <option value="肉类">肉类</option>

                    </select>
                </div>
                <table class="table">
                    <thead>
                    <tr>
                        <td>商品名称</td>
                        <td>件数</td>
                        <td>销售金额</td>
                    </tr>
                    </thead>
                    <tbody id="rixiao">

                    </tbody>
                </table>
            </div>

            <div class="money" id="container-money">
                <div class="right_top">
                    月销售量
                    <select class="op" id="select4">
                        <option value="0">--请选择月份--</option>
                        <option value="01">01</option>
                        <option value="02">02</option>
                        <option value="03">03</option>
                        <option value="05">04</option>
                        <option value="06">06</option>
                        <option value="07">07</option>
                        <option value="08">08</option>
                        <option value="09">09</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                    </select>
                    <select class="op" id="select2" >
                        <option value="0">--请选择商品种类--</option>
                        <option value="男装">男装</option>
                        <option value="女装">女装</option>
                        <option value="运功户外">运动户外</option>
                        <option value="家居用品">家居用品</option>
                        <option value="医疗保健">医疗保健</option>
                        <option value="家具用品">家具用品</option>
                        <option value="洗化">洗化</option>
                        <option value="家电">家电</option>
                        <option value="肉类">肉类</option>
                    </select>
                    <button class="btn btn-danger" id="select22" onclick="selectKind22()">查询</button>
                </div>
                <table class="table">
                    <thead>
                    <tr>
                        <td>商品名称</td>
                        <td>件数</td>
                        <td>销售金额</td>
                    </tr>
                    </thead>
                    <tbody id="yuexiao">

                    </tbody>
                </table>
                <a id="daochu" class="btn btn-danger" href="${pageContext.request.contextPath}/DaoChuServlet.do">导出Excel</a>
            </div>

            <div class="wp"  id="container-star">
                <input type="hidden" value="container-myorder" name="flag">
                <div class="right_top">
                    月销售 TOP10
                </div>
                <div id="star"></div>
            </div>
            <div class="wp"  id="container-luck-lottery">

                <div class="right_top">
                    我们的用户
                </div>
                <table class='table table-hover'>
                <tr>
                    <td>用户名</td>
                    <td>电话</td>
                    <td>邮箱</td>
                     <td>性别</td>
                    <td>生日</td>
                </tr>
                    <tbody id="uuu">
                    </tbody>
                </table>
                <div class="fenye">
                    <a href="#" onclick="getPage(1)">首页</a>
                    <a href="#" onclick="getPage(2)">上一页</a>
                    <a href="#" onclick="getPage(3)">下一页</a>
                    <a href="#" onclick="getPage(4)">尾页</a>
                </div>


            </div>
            <div id="container-password">
                <div class="right_top">
                    迄今为止本网站访问量
                </div>
                <div>
                    嗨购购物网站:
                </div>
                <div id="liang">

                </div>

            </div>
            <div id="container-add">
                <div class="right_top">
                    添加商品
                </div>
                <form role="form" action="${pageContext.request.contextPath}/GoodBeatchServlet.do" method="post" enctype="multipart/form-data">
                    <input type="hidden" value="container-add" name="flag">
                    <div id="shangpin">
                        <div class="form-group">
                            <input type="file" id="inputfile"name="goods">
                        </div>
                        <button type="submit" id="kkk" class="btn btn-danger">提交</button>
                    </div>
                </form>
                <hr style="border-bottom: 1px solid #dbd6d0" />
                <div id="tianjia">
                    <div  class="form-inline">
                    <%--<form action="" method="post" class="form-inline">--%>
                        <table>
                            <tr class="form-group">
                                <td>
                                    &nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;类别：<select  class="op" id="k_id">
                                    <option>--请选择商品种类--</option>
                                </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;商品名称：<input  class="form-control" type="text" name="g_name" id="g_name" value="" />
                                </td>
                            </tr>
                            <tr class="form-group">
                                <td>
                                    描述：<textarea  class="form-control" id="g_key" rows="5" cols="27" placeholder=""></textarea>&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;简介：<textarea  class="form-control" id="g_info" rows="5" cols="27" placeholder=""></textarea>
                                </td>
                            </tr>
                            <tr class="form-group">
                                <td>
                                    &nbsp;&nbsp;	&nbsp;&nbsp;&nbsp;&nbsp;现价：<input  class="form-control" type="text" name="g_now" id="g_now" value="" />&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;商品图片：<input class="form-control" type="text" type="text" id="g_img"/>
                                </td>
                            </tr>
                            <tr class="form-group">
                                <td>
                                    库存数量：<input  class="form-control" type="number" name="g_num" id="g_num" value="" />&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;上架日期： <input class="form-control" type="text" onclick="WdatePicker()" name="g_date" id="g_date" readonly="readonly"/>
                                </td>
                            </tr>
                            <tr class="form-group">
                                <td>
                                    活动标识：<select class="op" id="e_id">
                                    <option value="0">--请选择活动标示--</option>
                                </select>
                                    &nbsp;&nbsp;&nbsp;

                                </td>
                            </tr>
                            <tr >
                                <td>
                                    <button id="charus" class="btn btn-danger ti" type="button">提交</button>
                                </td>
                            </tr>
                        </table>
                    </div>

                </div>


            </div>
            <div id="container-del">
                <div class="right_top">
                    商品明细
                </div>
                <div id="mingxi"></div>
                <%--修改商品信息--%>
                <div id="lightboxx"></div>
                    <div id="popp">
                    <input type="hidden" id="g_id" name="g_id" value="">
                    <table width="100%" border="0" cellpadding="5" cellspacing="5">
                        <tr><th colspan="2">修改商品信息</th>
                            <table class="xinz">
                                <tr class="form-group">
                                    <td>*商品名称：</td>
                                    <td>
                                        <input class="form-control" type="text" name="g_name" id="g_names" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>*现价:</td>
                                    <td>
                                        <input type="number"class="sel_pp" name="g_now" id="g_nows">
                                    </td>
                                    <td></td>
                                </tr>
                                <tr class="form-group">
                                    <td>*库存数：</td>
                                    <td>
                                        <input type="number" name="g_num" id="g_nums">
                                    </td>
                            </table>
                        <tr><td colspan="2" align="right"><input id="didiii" type="button" value="保存" />　<input type="button" value="关闭" onclick="PoppLayer()" /> </td></tr>
                    </table>
                </div>

            </div>

            <div id="container-changing">
                <div class="right_top">
                    促销与种类管理
                </div>
                <div class="shu">
                    <input class="z" type="button" name="" id="btn1" value="首页促销" />
                    <input type="button" name="" id="btn2" value="添加商品种类" />
                    <input type="button" name="" id="btn3" value="添加活动标识" />
                </div>
                <div id="imgBox">
                    <div class="xian" id="imgBox1">
                        <div class="tian">
                            <form action="${pageContext.request.contextPath}/UpPlayServlet.do" method="post" class="form-inline" enctype="multipart/form-data">
                                <table>
                                    <div class="tian">
                                        <input type="file" name="p_img" id="p_img"/>
                                        <span style="color: red">上传轮播图</span>
                                        <br /><br /><br />
                                        <button class="btn btn-danger" type="submit"onclick="windows.reload()">添加</button>
                                    </div>
                                </table>
                            </form>
                        </div>
                    </div>
                    <div class="xian" id="imgBox2" >
                        <div class="form-inline">
                            <table>
                                <div class="tian">
                                    商品种类名称：
                                    <input class="form-control" type="text" name="k_name" id="k_name" />
                                    <br /><br /><br />
                                    <br /><button id="zhonglei" class="btn btn-danger" type="submit">添加</button>
                                </div>
                            </table>
                        </div>
                    </div>
                    <div class="xian" id="imgBox3">
                        <div class="form-inline">
                            <table>
                                <div class="tian">
                                    活动标识名称：
                                    <input class="form-control" type="text" name="e_name" id="e_name" />
                                    <br /><br /><br />
                                    活动折扣：
                                    <input class="form-control" type="number" name="e_dis" id="e_dis" />
                                    <br /><br /><br />
                                    <br /><button class="btn btn-danger" id="biaoshi" type="submit">添加</button>
                                </div>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    jQuery("#${param.flag}").addClass('dingdan');
</script>

<script type="text/javascript">
    var flag="${requestScope.flag}";
    if(flag)
    {
        alert("添加成功");
    }
    $('.centerLeft a').click(function(e){
        e.preventDefault();
        //修改li的dingdan的位置
        $(this).parent().addClass('dingdan').siblings('.dingdan').removeClass('dingdan');

        //修改右侧主体中的div的dingdan的位置
        var id = $(this).attr('href');
        if(id!="#${param.flag}")
        {
            $(id).addClass('dingdan').siblings('.dingdan').removeClass('dingdan');
        }
        //销售明星
        if (id=="#container-star") {
            jQuery.post("${pageContext.request.contextPath}/OrderServlet.do",function (data) {
                var div="";
                jQuery.each(data,function (i,item) {
                    if (i%2==0){
                        div+="<div style='height: 20px;width:"+(item.NUMS*20+80)+"px;background-color: chartreuse;margin-bottom: 10px;" +
                            "margin-left: 20px;margin-top: 20px;'>";
                        div+=item.NAME;
                        div+="    "+item.NUMS;
                        div+="</div>";
                    } else {
                    div+="<div style='height: 20px;width:"+(item.NUMS*20+80)+"px;background-color: rosybrown;margin-bottom: 10px;" +
                        "margin-left: 20px;margin-top: 20px;'>";
                    div+=item.NAME;
                    div+="    "+item.NUMS;
                    div+="</div>";
                    }
                });
                jQuery("#star").html(div);

            },"json");
        }
        //查询用户信息
        if(id=="#container-luck-lottery")
        {
            jQuery.post("${pageContext.request.contextPath}/FenYeServlet.do",function (data) {
                var tr="";
                jQuery.each(data,function (i,item) {
                    tr+="<tr>";
                    tr+="<td>";
                    tr+=item.U_NAME;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.U_TEL;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.U_EMAIL;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.U_SEX;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.U_BIRTH;
                    tr+="</td>";
                    tr+="</tr>";
                });
                jQuery("#uuu").html(tr);
            },"JSON");
        }


        //添加商品
        if(id=="#container-add")
        {
            jQuery.post("HuoQuZhongLeiServlet.do",function (data) {
                var str="";
                jQuery.each(data,function (i,item) {
                    str+="<option value='"+item.K_ID+"'>";
                    str+=item.K_NAME;
                    str+="</option>";
                });
                jQuery("#k_id").html(str);
            },"JSON");
            jQuery.post("HuoQuBiaoShiServlet.do",function (data) {
                var str="";
                jQuery.each(data,function (i,item) {
                    str+="<option value='"+item.E_ID+"'>";
                    str+=item.E_NAME;
                    str+="</option>";
                });
                jQuery("#e_id").html(str);
            },"JSON");
        }
        //添加商品种类
        //控件的id
        if (id=="#container-changing") {
            //提交按钮的id
            jQuery("#zhonglei"). click(function () {
                    var k_name=$("#k_name").val();
                    $.ajax({
                        url:"${pageContext.request.contextPath}/AddKindServlet.do",
                        data:{"k_name":k_name},
                        type:"post",
                        dataType:"json",
                        success:function(data){
                            alert(data.infos);
                        }
                    });
                }
            )
            jQuery("#huongdong"). click(function () {
                    var e_name=$("#e_name").val();
                    var e_dis=$("#e_dis").val();
                //取的数据
                    var k_name=$("#k_name").val();
                    $.ajax({
                        url:"${pageContext.request.contextPath}/AddKindServlet.do",
                        data:{"k_name":k_name},
                        url:"${pageContext.request.contextPath}/AddEventServlet.do",
                        data:{"e_name":e_name,"e_dis":e_dis},
                        type:"post",
                        dataType:"json",
                        success:function(data){
                            alert("添加成功");
                        },
                        error:function(){
                            alert("添加失败");
                        }
                    });
                }
            )
        }
        <%--//商品明细修改--%>
            if (id=="#container-del") {
                //提交按钮的id
                jQuery("#didiii"). click(function () {
                        var g_names=$("#g_names").val();
                        var g_nows=$("#g_nows").val();
                        var g_nums=$("#g_nums").val();
                        var g_id =$("#g_id").val();
                        $.ajax({
                            url:"${pageContext.request.contextPath}/UpdateGoodServlet.do",
                            data:{"g_names":g_names,"g_nows":g_nows,"g_nums":g_nums,"g_id":g_id},
                            type:"post",
                            dataType:"json",
                            success:function(data){
                                alert("修改成功");
                                jQuery.post("${pageContext.request.contextPath}/QueryGoodServlet.do",function (data) {
                                    var tr="";
                                    tr+="<table class='table table-hover'>";
                                    tr+="<tr>";
                                    tr+="<td>商品编号</td>"
                                    tr+="<td>商品名称</td>";
                                    tr+=" <td>现价</td>";
                                    tr+=" <td>库存数</td>";
                                    tr+=" <td>操作</td>";
                                    tr+="</tr>";
                                    tr+="<tbody>";
                                    jQuery.each(data,function (i,item) {
                                        tr+="<tr>";
                                        tr+="<td>";
                                        tr+=item.G_ID;
                                        tr+="</td>";
                                        tr+="<td>";
                                        tr+=item.G_NAME;
                                        tr+="</td>";
                                        tr+="<td>";
                                        tr+=item.G_NOW;
                                        tr+="</td>";
                                        tr+="<td>";
                                        tr+=item.G_NUM;
                                        tr+="</td>";
                                        tr+="<td>";
                                        tr+="<button type='button' class='btn btn-danger' name='g_id' " +
                                            "onclick=\"return PoppLayer(this,'"+item.G_ID+"','"+item.G_NAME+"','"+item.G_NOW+"','"+item.G_NUM+"')\">修改</button>";
                                        tr+="<button type='button' class='btn btn-danger' name='g_id' onclick='doDelete(this,"+item.G_ID+")'>删除</button>";
                                        tr+="</td>";
                                        tr+="</tr>";
                                    });
                                    tr+="</tbody>";
                                    tr+=" </table>";
                                    jQuery("#mingxi").html(tr);
                                },"JSON");
                            },
                            error:function(){
                                alert("修改失败");
                            }
                        });
                    }
                )
            }
        //商品明细
        if(id=="#container-del")
        {
            jQuery.post("${pageContext.request.contextPath}/QueryGoodServlet.do",function (data) {
                var tr="";
                tr+="<table class='table table-hover'>";
                tr+="<tr>";
                tr+="<td>商品编号</td>"
                tr+="<td>商品名称</td>";
                tr+=" <td>现价</td>";
                tr+=" <td>库存数</td>";
                tr+=" <td>操作</td>";
                tr+="</tr>";
                tr+="<tbody>";
                jQuery.each(data,function (i,item) {
                    tr+="<tr>";
                    tr+="<td>";
                    tr+=item.G_ID;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.G_NAME;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.G_NOW;
                    tr+="</td>";
                    tr+="<td>";
                    tr+=item.G_NUM;
                    tr+="</td>";
                    tr+="<td>";
                    tr+="<button type='button' class='btn btn-danger' name='g_id' " +
                        "onclick=\"return PoppLayer(this,'"+item.G_ID+"','"+item.G_NAME+"','"+item.G_NOW+"','"+item.G_NUM+"')\">修改</button>";
                    tr+="<button type='button' class='btn btn-danger' name='g_id' onclick='doDelete(this,"+item.G_ID+")'>删除</button>";
                    tr+="</td>";
                    tr+="</tr>";
                });
                tr+="</tbody>";
                tr+=" </table>";
                jQuery("#mingxi").html(tr);
            },"JSON");
        }



        //单个插入商品
        if (id=="#container-add") {
            //提交按钮的id
            jQuery("#charus"). click(function () {
                    //取的数据
                    var k_id=$("#k_id").val();
                    var e_id=$("#e_id").val();
                    var g_name=$("#g_name").val();
                    var g_info=$("#g_info").val();
                    var g_key=$("#g_key").val();
                    var g_date=$("#g_date").val();
                    var g_now=$("#g_now").val();
                    var g_num=$("#g_num").val();
                    var g_img=$("#g_img").val();
                    var g_id=$("#g_id").val();
                    // var i=0;
                    $.ajax({
                        url:"${pageContext.request.contextPath}/GoodInsertServlet.do",
                        data:{"k_id":k_id,"e_id":e_id,"g_name":g_name,"g_info":g_info,"g_key":g_key,
                        "g_date":g_date,"g_now":g_now,"g_num":g_num,"g_img":g_img,"g_id":g_id},
                        type:"post",
                        dataType:"json",
                        async:false,
                        success:function(data){
                            alert("添加成功");

                        },
                        error:function(){
                            alert("添加失败");
                            alert(data.infos);
                        }
                    });
                }
            )
        }
    //添加活动标识
    //控件的id
    if (id=="#container-changing") {
        //提交按钮的id
        jQuery("#biaoshi"). click(function () {
                //取的数据
                var e_name=$("#e_name").val();
                var e_dis=$("#e_dis").val();
                $.ajax({
                    url:"${pageContext.request.contextPath}/AddEventServlet.do",
                    data:{"e_name":e_name,"e_dis":e_dis},
                    type:"post",
                    dataType:"json",
                    success:function(data){
                        alert("添加成功");
                    },
                    error:function(){
                        alert("添加失败");
                    }
                });
            }
        )
    }
    });

    //月销售量
    function selectKind22() {
        var k_name=document.getElementById("select2").value;
        var month=document.getElementById("select4").value;
        jQuery.post("${pageContext.request.contextPath}/MonthSaleServlet.do",{"k_name":k_name,"month":month},function (data) {
            var tr="";
            jQuery.each(data,function (i,item) {
                tr+="<tr>";
                tr+="<td>";
                tr+=item.G_NAME;
                tr+="</td>";
                tr+="<td>";
                tr+=item.NUMS;
                tr+="</td>";
                tr+="<td>";
                tr+=item.PRICES;
                tr+="</td>";
                tr+="</tr>";
            });
            jQuery("#yuexiao").html(tr);
        },"JSON");

    }
        //日销售量
    function selectKind1() {
        var k_name=document.getElementById("select1").value;
        jQuery.post("${pageContext.request.contextPath}/DaySaleServlet.do",{"k_name":k_name},function (data) {
            var tr="";
            jQuery.each(data,function (i,item) {
                tr+="<tr>";
                tr+="<td>";
                tr+=item.G_NAME;
                tr+="</td>";
                tr+="<td>";
                tr+=item.NUMS;
                tr+="</td>";
                tr+="<td>";
                tr+=item.PRICES;
                tr+="</td>";
                tr+="</tr>";
            });
            jQuery("#rixiao").html(tr);
        },"JSON");
    }

    function getPage(f)
    {
        jQuery.post("${pageContext.request.contextPath}/AjaxServlet.do",{"flag":f},function (data) {
            var tr="";
            jQuery.each(data,function (i,item) {
                tr+="<tr>";
                tr+="<td>";
                tr+=item.U_NAME;
                tr+="</td>";
                tr+="<td>";
                tr+=item.U_TEL;
                tr+="</td>";
                tr+="<td>";
                tr+=item.U_EMAIL;
                tr+="</td>";
                tr+="<td>";
                tr+=item.U_SEX;
                tr+="</td>";
                tr+="<td>";
                tr+=item.U_BIRTH;
                tr+="</td>";
                tr+="</tr>";
            });
            jQuery("#uuu").html(tr);
        },"JSON");
    }
    //删除商品明细
    function doDelete(obj,n) {
        $.ajax({
            url:"${pageContext.request.contextPath}/DeleteGoodServlet.do",
            data:{"g_id":n},
            type:"post",
            dataType:"json",
            success:function(data){
                alert("删除成功");
                jQuery.post("${pageContext.request.contextPath}/QueryGoodServlet.do",function (data) {
                    var tr="";
                    tr+="<table class='table table-hover'>";
                    tr+="<tr>";
                    tr+="<td>商品编号</td>"
                    tr+="<td>商品名称</td>";
                    tr+=" <td>现价</td>";
                    tr+=" <td>库存数</td>";
                    tr+=" <td>操作</td>";
                    tr+="</tr>";
                    tr+="<tbody>";
                    jQuery.each(data,function (i,item) {
                        tr+="<tr>";
                        tr+="<td>";
                        tr+=item.G_ID;
                        tr+="</td>";
                        tr+="<td>";
                        tr+=item.G_NAME;
                        tr+="</td>";
                        tr+="<td>";
                        tr+=item.G_NOW;
                        tr+="</td>";
                        tr+="<td>";
                        tr+=item.G_NUM;
                        tr+="</td>";
                        tr+="<td>";
                        tr+="<button type='button' class='btn btn-danger' name='g_id' " +
                            "onclick=\"return PoppLayer(this,'"+item.G_ID+"','"+item.G_NAME+"','"+item.G_NOW+"','"+item.G_NUM+"')\">修改</button>";
                        tr+="<button type='button' class='btn btn-danger' name='g_id' onclick='doDelete(this,"+item.G_ID+")'>删除</button>";
                        tr+="</td>";
                        tr+="</tr>";
                    });
                    tr+="</tbody>";
                    tr+=" </table>";
                    jQuery("#mingxi").html(tr);
                },"JSON");
            },
            error:function(){
                alert("删除失败");
            }
        });
    }
</script>
<script type="text/javascript">
    function showTime(){
        var date = new Date();
        var t = date.toLocaleString();
        document.getElementById("time").innerHTML=t;
    }
    setInterval("showTime()",1000);
</script>
<script type="text/javascript">
    function checkChAll(e){
        var all=document.getElementsByName("g_id");
        for(var i in all){
            all[i].checked=e;
        }
    }
</script>
<script>
    function PoppLayer(obj,a,b,c,d) {
        lightboxx.style.display = popp.style.display = obj ? 'block' : 'none';
        jQuery("#g_id").val(a);
        jQuery("#g_names").val(b);
        jQuery("#g_nows").val(c);
        jQuery("#g_nums").val(d);
        return false;
    }
</script>
<script>
    jQuery(function () {
        jQuery.post("${pageContext.request.contextPath}/VisitCountServlet.do",function (date) {
            jQuery("#liang").html(date);
        });
    });
</script>

<script type="text/javascript">
var btn1=document.getElementById("btn1");
var btn2=document.getElementById("btn2");
var btn3=document.getElementById("btn3");
var imgBox1=document.getElementById("imgBox1");
var imgBox2=document.getElementById("imgBox2");
var imgBox3=document.getElementById("imgBox3");
function xiaoshi(){
btn1.style.background="#f8f6f4";
btn2.style.background="#f8f6f4";
btn3.style.background="#f8f6f4";
btn1.style.color="#666";
btn2.style.color="#666";
btn3.style.color="#666";
imgBox1.style.display="none";
imgBox2.style.display="none";
imgBox3.style.display="none";
}
btn1.onclick=function(){
xiaoshi();
btn1.style.background="white";
btn1.style.color="red";
imgBox1.style.display="flex";

}
btn2.onclick=function(){
xiaoshi();
btn2.style.background="white";
btn2.style.color="red";
imgBox2.style.display="flex";
}
btn3.onclick=function(){
xiaoshi();
btn3.style.background="white";
btn3.style.color="red";
imgBox3.style.display="flex";
}
</script>

</html>